﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;
using GoodMan.Infrastructure.Entities.Enum;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Refund : IAccessible<T_Refund, Refund>, ILogicEntity<T_Refund, Refund>
    {
        public int Id { get; set; }
        public DateTime ApplyDate { get; set; }
        public string ApplyUserName { get; set; }
        public string Remark { get; set; }
        public decimal Total { get; set; }
        public RefundStatus Status { get; set; }
        public DateTime HandleDate { get; set; }
        public string HandleUserName { get; set; }
        public string HandleRemark { get; set; }

        protected override void Covariant(T_Refund model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.ApplyDate = model.ApplyDate;
                this.ApplyUserName = model.ApplyUserName;
                this.Remark = model.Remark;
                this.Total = model.Total;
                this.Status = (RefundStatus)model.Status;
                this.HandleDate = model.HandleDate;
                this.HandleUserName = model.HandleUserName;
                this.HandleRemark = model.HandleRemark;
            }
        }

        protected override T_Refund Inverter(Refund model)
        {
            if (model != null)
            {
                return new T_Refund()
                {
                    ApplyDate = model.ApplyDate,
                    ApplyUserName = model.ApplyUserName,
                    HandleDate = model.HandleDate,
                    HandleRemark = model.HandleRemark,
                    HandleUserName = model.HandleUserName,
                    Id = model.Id,
                    Remark = model.Remark,
                    Status = (int)model.Status,
                    Total = model.Total
                };
            }
            return null;
        }

        public Refund Set(T_Refund dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
